/*
* @Date: 2020/4/28
* @Author: XueChengwu <xuechengwu@erayt.com>
* @Copyright: 2015-2019 Erayt, Inc.
* @Description: If you have some questions, please contact: xuechengwu@erayt.com.
*/
const { app, Menu, webContents  } = require('electron');

const template = [{
  label: '文件',
  submenu: [{
    label: '新建',
    submenu: [{
      label: '工程',
      click: (e, focusedWindow, focusedWebContents) => {
        //console.log(e);
        //ipcMain.send('context-menu', 'newproject');
        //console.log(focusedWindow);
        app.mainWin.webContents.executeJavaScript('XUE.win.emit("newproject", "context-menu")');
      }
    }, {
      label: '文件'
    }]
  }, {
    label: '打开'
  }]
}, {
  label: '编辑',
  submenu: [{
    label: '撤销',
    role: 'undo'
  }, {
    label: '重做',
    role: 'redo'
  }, {
    role: 'separator'
  }, {
    label: '剪切',
    role: 'cut'
  }, {
    label: '复制',
    role: 'copy'
  }, {
    label: '粘贴',
    role: 'paste'
  }, {
    label: '删除',
    role: 'delete'
  }, {
    role: 'separator'
  }, {
    label: '全选',
    role: 'selectAll'
  }]
}];
const menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);
